﻿using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using CustomControlPractice;

namespace Microsoft.Coral.Web.Controls
{
    public partial class TreeSelectionPanel : UserControl
    {

        public string Selected
        {
            get { return treeview.SelectedValue; }
        }

        public void BindData(List<Hospital> data)
        {
            treeview.Nodes.Clear();
            data.ForEach(delegate(Hospital hospital)
                             {
                                 TreeNode node = new TreeNode(hospital.Name);
                                 foreach(var department in hospital.Departments)
                                 {
                                     TreeNode departmentNode = new TreeNode(department.Name,department.ID.ToString());
                                     node.ChildNodes.Add(departmentNode);
                                 }
                                 treeview.Nodes.Add(node);
                             });
            
        }

        protected void OnSelectedNodeChanged(object sender, EventArgs e)
        {
            
        }
    }
}